All Questions
9 questions
-3votes
1answer
80views
Will this time duration measurement in two threads give correct result?
A program I'm developing has two threads running similar but different task: thread1: timer1.start() writeToExternalDB1(consumedData) timer1.end() thread2: timer2.start() writeToExternalDB2(...
1vote
2answers
529views
What do you call a class that can be disabled [closed]
Is there a design pattern that fits this description? A factory that creates classes that can be disabled and enabled. The users of the class don't know if the functionality is enabled or disabled--...
9votes
1answer
9kviews
Why use ExecutorService for long-running thread?
I want an object that will spawn a daemon thread that will continue to run for the lifetime of the process. Let's say, just for the sake of the argument, that it's a thread in an embedded system, and ...
1vote
1answer
238views
«Heavy» object initialization: within each thread or outside and then pass it to the threads as parameter?
Let say there is an array of strings, I have to process. I'm using a «heavy» third-part object which gets the string and performs its analysis. In order to optimize a performance, I create a number of ...
4votes
3answers
2kviews
Transitioning from C++ multithreading to Java multithreading
In C++, I've been accustomed to using threads in the following way: #include <iostream> #include <thread> #include <mutex> std::mutex m; int i = 0; void makeACallFromPhoneBooth()...
0votes
2answers
491views
Built-in the separate thread execution inside of the method or wrap the method by the thread
Let assume, I have some resource and time-consuming code, which I want to arrange as a separate method. In order to optimize the performance, this code should be executed in the separate thread. Now ...
1vote
2answers
90views
Should I reference a CopyOnWriteArraySet from the Set interface?
There are two ways to use a CopyOnWriteArraySet: // A Set<Object> set = new CopyOnWriteArraySet<>(); and // B CopyOnWriteArraySet<Object> set = new CopyOnWriteArraySet<>(); ...
3votes
5answers
3kviews
Should I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority?
Can I build a multi-threaded system that handles events from a game and sorts them, independently, into different threads based on priority, and is it a good idea? Here's more info: I am about to ...
0votes
1answer
60views
Where to put profile test?
I have an application with multiple threads that may be run on different hardware. To assist with tuning on different hardware I would like to create a "profiler" that can automatically run a fixed ...